// src/api/dashboard.js
export const fetchDashboardData = (role, period) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      const mockData = {
        1: { // 总经理
          周: { categories: ['一', '二', '三', '四', '五', '六', '日'], series: [{ name: '订单数', data: [120,135,148,142,165,203,189] }] },
          月: { categories: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'], series: [{ name: '订单数', data: [35,42,58,63,72,85,91,98,105,112,128,142] }] },
          年: { categories: ['2022','2023','2024'], series: [{ name: '订单数', data: [2847,3200,2100] }] }
        },
        3: { // 销售
          周: { categories: ['一', '二', '三', '四', '五', '六', '日'], series: [{ name: '订单数', data: [18,22,25,28,32,38,42] }] },
          月: { categories: ['1月','2月','3月','4月','5月','6月','7月','8月'], series: [{ name: '订单数', data: [23,28,35,42,48,52,58,63] }] },
          年: { categories: ['1月','2月','3月','4月','5月','6月','7月','8月'], series: [{ name: '订单数', data: [23,28,35,42,48,52,58,63] }] }
        },
        4: { // 客服
          周: { categories: ['一', '二', '三', '四', '五', '六', '日'], series: [{ name: '发货数', data: [45,52,48,60,72,88,95] }] },
          月: { categories: ['1月','2月','3月','4月','5月','6月','7月','8月'], series: [{ name: '发货数', data: [184,192,205,218,230,245,260,275] }] },
          年: { categories: ['1月','2月','3月','4月','5月','6月','7月','8月'], series: [{ name: '发货数', data: [184,192,205,218,230,245,260,275] }] }
        }
      }

      const trend = mockData[role]?.[period] || mockData[role]?.月
      const stats = { total: Math.floor(Math.random() * 1000) + 100 }

      resolve({ trend, stats })
    }, 600)
  })
}